﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WuDada.Core.Post.Domain;
using WuDada.Core.Post.Persistence;

namespace WuDada.Core.Post.Service.Impl
{
    public class AttachedFileService : IAttachedFileService
    {
        public IAttachedFileDao AttachedFileDao { get; set; }

        /// <summary>
        /// 新增AttachedFile
        /// </summary>
        /// <param name="attachedFileVO">被新增的AttachedFile</param>
        /// <returns>新增後的AttachedFile</returns>
        public AttachedFileVO CreateAttachedFile(AttachedFileVO attachedFileVO)
        {
            return AttachedFileDao.CreateAttachedFile(attachedFileVO);
        }

        /// <summary>
        /// 取得AttachedFile By AttachedFileId
        /// </summary>
        /// <param name="attachedFileId">AttachedFileId</param>
        /// <returns>AttachedFile</returns>
        public AttachedFileVO GetAttachedFileById(int attachedFileId)
        {
            return AttachedFileDao.GetAttachedFileById(attachedFileId);
        }

        /// <summary>
        /// 取得AttachedFile By PostId
        /// </summary>
        /// <param name="postId">PostId</param>
        /// <param name="fileType">檔案類別</param>
        /// <returns>AttachedFile清單</returns>
        public IList<AttachedFileVO> GetAttachedFileListByPostId(int postId, AttachedFileVO.Type fileType)
        {
            return AttachedFileDao.GetAttachedFileListByPostId(postId, fileType);
        }

        /// <summary>
        /// 刪除AttachedFile
        /// </summary>
        /// <param name="attachedFileVO">被刪除的AttachedFile</param>
        public void DeleteAttachedFile(AttachedFileVO attachedFileVO)
        {
            AttachedFileDao.DeleteAttachedFile(attachedFileVO);
        }

        /// <summary>
        /// 更新AttachedFile
        /// </summary>
        /// <param name="attachedFileVO">被更新的AttachedFile</param>
        /// <returns>更新後的AttachedFile</returns>
        public AttachedFileVO UpdateAttachedFile(AttachedFileVO attachedFileVO)
        {
            return AttachedFileDao.UpdateAttachedFile(attachedFileVO);
        }

        /// <summary>
        /// 取得AttachedFile By PostId
        /// </summary>
        /// <param name="postId">PostId</param>
        /// <param name="onlyShow">僅抓取上架</param>
        /// <param name="fileType">檔案類別</param>
        /// <param name="sortField">排序欄位</param>
        /// <param name="sortDesc">升降冪排序</param>
        /// <returns>AttachedFile清單</returns>
        public IList<AttachedFileVO> GetAttachedFileListByPostId(int postId, bool onlyShow, AttachedFileVO.Type fileType, string sortField, bool sortDesc)
        {
            return AttachedFileDao.GetAttachedFileListByPostId(postId, onlyShow, fileType, sortField, sortDesc);
        }

        /// <summary>
        /// 取得AttachedFile By PostId
        /// </summary>
        /// <param name="postId">PostId</param>
        /// <param name="onlyShow">僅抓取上架</param>
        /// <param name="fileType">檔案類別</param>
        /// <param name="startDate">起始的上架日期</param>
        /// <param name="pageIndex">分頁索引</param>
        /// <param name="pageSize">分頁大小</param>
        /// <param name="sortField">排序欄位</param>
        /// <param name="sortDesc">升降冪排序</param>
        /// <returns>AttachedFile清單</returns>
        public IList<AttachedFileVO> GetAttachedFileListByPostId(int postId, bool onlyShow, AttachedFileVO.Type fileType, DateTime? startShowDate
            , int pageIndex, int pageSize, string sortField, bool sortDesc)
        {
            return AttachedFileDao.GetAttachedFileListByPostId(postId, onlyShow, fileType, startShowDate, pageIndex, pageSize, sortField, sortDesc);
        }

        /// <summary>
        /// 取得AttachedFile筆數 By PostId
        /// </summary>
        /// <param name="postId">PostId</param>
        /// <param name="onlyShow">僅抓取上架</param>
        /// <param name="fileType">檔案類別</param>
        /// /// <param name="startDate">起始的上架日期</param>
        /// <returns>AttachedFile清單</returns>
        public int CountAttachedFileListByPostId(int postId, bool onlyShow, AttachedFileVO.Type fileType, DateTime? startShowDate)
        {
            return AttachedFileDao.CountAttachedFileListByPostId(postId, onlyShow, fileType, startShowDate);
        }        
    }
}
